package morego_go_client

import (
	"compress/gzip"
	"bytes"
	"fmt"
	"net"
)


func handleClientMsgSingle(conn *net.TCPConn,   sid string) {

	//声明一个管道用于接收解包的数据
	//reader := bufio.NewReader(conn)
	reader, _ := gzip.NewReader(conn)
	size:=make([]byte,4096)
	for {
		buf, err := reader.Read(size)
		if err!=nil{
			fmt.Println( "err: ",err.Error())
			conn.Close()
			break
		}
		//fmt.Println( "HandleConn str: ",string(buf))

		fmt.Println( "HandleConn str: ",string(size[:buf]))


		//conn.Write(size[:buf])

	}
}

func send_msg( conn *net.TCPConn, data string, times int){

	var b  bytes.Buffer
	w:=gzip.NewWriter(&b)

	w.Write([]byte(data))
	w.Flush()
	w.Close()
	buf:=b.Bytes()
	for i:=0;i<times;i++{

		conn.Write(buf)
	}
	conn.Close()

}

